<?php
class SystemConfiguration{	
	function getConfig($param) {
		global $dbi;
		
		$sql = "SELECT ".$param." FROM systemconfiguration order by ".$param." desc limit 0,1";
		
		$row = $dbi->get_row($sql);
		
		return $row->$param;
	}
	
	function isSiteOffline() {
		return $this->getConfig("site_status");
	}
	
	function getStatusOffline() {
		return $this->getConfig("offline_message");
	}
	
	function getErrorMessage() {
		return $this->getConfig("error_message");
	}
	
	function getSiteName() {
		return $this->getConfig("site_name");
	}
	
	function getPagesLimit() {
		return $this->getConfig("pages_limit");	
	}
	
	function getFavicon() {
		return $this->getConfig("favourites_icon");
	}
	
	function getTimeOffset() {
		return $this->getConfig("time_offset");
	}
	
	function getServerOffsite() {
		return $this->getConfig("server_offset");
	}
	
	function getCountryLocale() {
		return $this->getConfig("country_locale");
	}
	
	function getErrorReporting() {
		return $this->getConfig("error_reporting");
	}
	
	function getMetaDescription() {
		return $this->getConfig("meta_description");
	}
	
	function getMetaKeywords() {
		return $this->getConfig("meta_keywords");
	}
	
	function getDefaultMail() {
		return $this->getConfig("default_mail");
	}
	
	function getWebMasterMail() {
		return $this->getConfig("webmaster_mail");
	}
	
	function getMailFromName() {
		return $this->getConfig("from_name");
	}
	
	function getEditForm() {
		return $this->getConfig("edit_form");
	}
	
	function updateData($arrFields, $arrVals, $conds) {
		global $dbi, $log, $auth;

		if(sizeof($arrFields)>0 && sizeof($arrVals)>0) {
			$dbi->create_update("systemconfiguration");
			for($x=0;$x<sizeof($arrFields);$x++) {
				$dbi->add_update($arrFields[$x], $arrVals[$x]);
			}

			$dbi->set_condition($conds);
			$dbi->execute();

			$log->insertData($auth->getUserName() . " was updating system configuration on ". date("Y-m-d H:i:s"));
		}
	}
}
?>